package com.github.wendao76.test.thread;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * 线程A
 *
 * @author wendao76
 * @version 1.0
 * @since 2022-2-5
 */
public class ThreadClsA extends Thread {
  CountDownLatch countDownLatch;
  private int num;

  public ThreadClsA(int num, CountDownLatch cdl) {
    this.countDownLatch = cdl;
    this.num = num;
    this.setName("ThreadClsA");
  }

  @Override
  public void run() {
    try {
      TimeUnit.SECONDS.sleep(3);
      countDownLatch.countDown();
      System.out.println(this.getName() + "-" + this.num + ":" + System.currentTimeMillis());
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
